package com.jzx.provider.cv.controller;

import com.jzx.provider.common.result.InvokeResult;
import com.jzx.provider.cv.dto.command.EducationInfoCommand;
import com.jzx.provider.cv.dto.command.WorkInfoCommand;
import com.jzx.provider.cv.service.WorkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Size;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
@Validated
@RestController
@RequestMapping("/work")
public class WorkInfoController {
    @Autowired
    private WorkInfoService workInfoService;

    @PostMapping("/saveOrUpdate")
    public InvokeResult<Void> saveOrUpdate(@RequestBody @Validated WorkInfoCommand workInfoCommand) {
        workInfoService.saveOrUpdate(workInfoCommand);
        return InvokeResult.success();
    }

    @GetMapping("/del/{id}")
    public InvokeResult<Void> deleteWork(@PathVariable Integer id) {
        workInfoService.deleteWork(id);
        return InvokeResult.success();
    }

    @PostMapping("/saveOrUpdateWorkInfo")
    public InvokeResult saveOrUpdateWorkInfo(@RequestBody @Validated WorkInfoCommand workInfoCommand) {
        workInfoService.saveOrUpdateWorkInfo(workInfoCommand);
        return InvokeResult.success();
    }
}
